﻿using HandyControl.Controls;
using Jot;
using Jot.Storage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StickyNote.Services
{
    public class JotService
    {
        public Tracker Tracker = new Tracker(new JsonFileStore(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\StickyNote\\Notes"));

        /// <summary>
        /// 获取已保存的数据
        /// </summary>
        /// <param name="propertyName">属性名称</param>
        /// <param name="id">属性所属分类</param>
        /// <returns></returns>
        public object GetData(string id, string propertyName, object defaultValue = null)
        {
            IDictionary<string, object> Data = new Dictionary<string, object>();
            var dic = Tracker.Store.GetData(id);
            if (dic != null)
            {
                if (dic.ContainsKey(propertyName) && dic[propertyName] != null)
                {
                    return dic[propertyName];
                }
            }

            return defaultValue;
        }
    }
}
